﻿var editors = new Array();

function myFileBrowser(field_name, url, type, win) {
    tinyMCE.activeEditor.windowManager.open({ file: serviceUrl + '?ed=tmc&type=' + type, title: 'File Browser', width: 860, height: 700, resizable: 'yes', inline: 'yes', close_previous: 'no' }, { window: win, input: field_name }); return false;
}

function TinyMCESetupEditor(host, controlId, cleanGuid) {

    editors[controlId] = new tinymce.Editor(controlId, {
        accessibility_focus: true,
        browsers: "msie,gecko,safari,opera",
        forced_root_block: 'p',
        convert_urls: false,
        entity_encoding: 'raw',
        dialog_type: "modal",
        language: 'en',
        extended_valid_elements: "iframe[src|width|height|style|name|title|align|scrolling|frameborder|allowtransparency]",
        directionality: "ltr",
        editor_deselector: "mceNoEditor",
        spellchecker_rpc_url: host + "/TinyMCEHandler.ashx?rp=spellchecker",
        body_class: 'wysiwygeditor',
        plugins: "media,template,paste,print,searchreplace,fullscreen,emotions,directionality,table,contextmenu,advimage,inlinepopups,spellchecker,wordcount,safari",
        theme: "advanced",
        custom_undo_redo_levels: 10,
        layout_manager: "SimpleLayout",
        theme_advanced_blockformats: "p,address,pre,h1,h2,h3,h4,h5,h6",
        theme_advanced_styles: "FloatPanel=floatpanel,Image on Right=floatrightimage,Image on Left=floatleftimage",
        theme_advanced_source_editor_width: "780",
        theme_advanced_source_editor_height: "700",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_buttons1: "code,separator,selectall,removeformat,cleanup,cut,copy,separator,paste,pastetext,pasteword,separator,print,separator,undo,redo,separator,search,replace",
        theme_advanced_buttons2: "blockquote,bold,italic,underline,strikethrough,separator,sub,sup,separator,bullist,numlist,separator,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,link,unlink,anchor,image,media,table,hr,emotions,charmap",
        theme_advanced_buttons3: "template,formatselect,styleselect,separator,cleanup,fullscreen,spellchecker",
        theme_advanced_resizing: true,
        template_external_list_url: host + "/Services/TinyMceTemplates.ashx?cb=" + cleanGuid,
        content_css: host + "/csshandler.ashx?skin=blackhouse&amp;s=1&amp;sv=" + cleanGuid,
        emotions_images_url: '/Data/SiteImages/emoticons/tinymce/',
        file_browser_callback: 'myFileBrowser',
        onchange_callback: 'mojoTinyMCEOnChangeHandler'
    });
    editors[controlId].render();
}